import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/layout',
    name: 'layout',
    component: () => import('@/views/layout/layout.vue'),
    children: [
      {
        path: '/user',
        name: 'user',
        component: () => import('@/views/layout/user/index.vue')
      },
      {
        path: '/find',
        name: 'find',
        component: () => import('@/views/layout/find/index.vue')
      },
      {
        path: '/doExercise',
        name: 'doExercise',
        component: () => import('@/views/layout/doExercise/index.vue')
      },
      {
        path: '/company',
        name: 'company',
        component: () => import('@/views/layout/company/index.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404.vue')
  }
]

const router = new VueRouter({
  routes
})

// 导航守卫
router.beforeEach((to, from, next) => {
  // ...
})

// 后置钩子
router.afterEach((to, from) => {
  // ...
})

export default router
